package com.theobserver.theobserver;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.avos.avoscloud.AVObject;

import org.w3c.dom.Text;

import java.util.ArrayList;

/**
 * Created by wssxk on 7/13/17.
 */

public class NewsCommentAdapter extends BaseAdapter {
    public ArrayList<AVObject> comments = null;
    public Context mContext = null;

    public NewsCommentAdapter(Context c)
    {
        mContext = c;
        comments = new ArrayList<>();
    }

    public int getCount()
    {
        return comments.size();
    }

    public Object getItem(int pos)
    {
        return null;
    }

    public long getItemId(int pos)
    {
        return pos;
    }

    public View getView(int pos, View convert, ViewGroup root)
    {
        View v = View.inflate(mContext, R.layout.news_comment_item, null);
        TextView comment_username = (TextView) v.findViewById(R.id.news_comment_item_username);
        TextView comment_content = (TextView) v.findViewById(R.id.textview_commentitem_commentcontent);
        comment_username.setText(comments.get(pos).getAVObject("user_email").getString("user_name"));
        comment_content.setText(comments.get(pos).getString("comment_content"));

        return v;
    }
}
